//
//  DYYoukeCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/2/4.
//  Copyright © 2021 叁拾叁. All rights reserved.
//



import UIKit


class DYYoukeInfoCell: SYBaseCell  {
    

    var bgView: UIView = {
        let v = UIView()
        v.backgroundColor = UIColor(hex: 0xE6F1FF)
        return v
    }()
    let imgView: UIImageView = {
        let v = UIImageView()
        v.image = UIImage(named: "people_close")
        return v
    }()
    let youke: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 16.autoFontSize()
        v.text = "游客"
        return v
    }()
    let nameLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 15.autoFontSize()
        return v
    }()
    let phone: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 15.autoFontSize()
        return v
    }()
    let zhengjian: UILabel = {
        let v:UILabel = UILabel()
        return v
    }()
    
    let bianji: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x4A8CF7)
        v.font = 13.autoFontSize()
        v.text = "编辑"
        return v
    }()
    
    
    let close: UIButton = {
        let v: UIButton  = UIButton()
        return v
    }()
    
    let edit: UIButton = {
        let v: UIButton  = UIButton()
        return v
    }()
    

    public func configureView(_ model: DYJQYuyuePeopleListModel) {
        nameLb.text = model.name
        phone.text = "手机号 \(model.mobile ?? "")"
        if String.isEmptyOrNil(model.idCard) {
            zhengjian.text = "缺少证件号，点击补全"
            zhengjian.textColor = UIColor(hex: 0xF55035)
            zhengjian.font = 11.autoFontSize()
        } else {
            zhengjian.text = model.idCard
            zhengjian.textColor = UIColor(hex: 0x333333)
            zhengjian.font = 15.autoFontSize()
        }
    }
    
    override func initViews() {
        
        close.addAction {[weak self] in
            if let `self` = self {
                self.clickedClosure?(0)
            }
        }
        edit.addAction {[weak self] in
            if let `self` = self {
                self.clickedClosure?(1)
            }
        }

        contentView.addSubview(bgView)
        contentView.addSubview(imgView)
        contentView.addSubview(youke)
        
        contentView.addSubview(nameLb)
        contentView.addSubview(phone)
        contentView.addSubview(zhengjian)

        contentView.addSubview(bianji)
        contentView.addSubview(close)
        contentView.addSubview(edit)


        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview().offset(autoWidth(15.0))
            make.right.equalToSuperview().offset(autoWidth(-15))
            make.height.equalTo(36.0.autoWidth())
        }
        
        imgView.snp.makeConstraints { (make) in
            make.centerY.equalTo(bgView)
            make.right.equalToSuperview().offset(autoWidth(-26.5))
            make.width.height.equalTo(8.0.autoWidth())
        }
        
        youke.snp.makeConstraints { (make) in
            make.centerY.equalTo(bgView)
            make.left.equalToSuperview().offset(autoWidth(25.5))
            make.height.equalTo(16.0.autoWidth())
        }
        
        nameLb.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(47.0))
            make.left.equalToSuperview().offset(autoWidth(35.0))
            make.height.equalTo(16.0.autoWidth())
        }
        
        bianji.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(47.0))
            make.right.equalToSuperview().offset(autoWidth(-20.0))
            make.height.equalTo(16.0.autoWidth())
        }
        phone.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(75.0))
            make.left.equalToSuperview().offset(autoWidth(35.0))
            make.height.equalTo(16.0.autoWidth())
        }
        zhengjian.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(103.0))
            make.left.equalToSuperview().offset(autoWidth(35.0))
            make.height.equalTo(16.0.autoWidth())
            make.bottom.equalToSuperview().offset(autoWidth(-11.0))
        }
        close.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.right.equalToSuperview()
            make.width.equalTo(86.0.autoWidth())
            make.height.equalTo(56.0.autoWidth())
        }
        edit.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(autoWidth(36.0))
            make.right.equalToSuperview()
            make.width.equalTo(86.0.autoWidth())
            make.height.equalTo(56.0.autoWidth())
        }
    }
}

